<template>
    <div class="header">
        <div class="l-content">
            <!-- 这个点击事件是控制菜单组件的收缩的 -->
            <el-button type="primary" size="small" @click="handleCollapse()">
                <component class="icons" is="menu"></component>
            </el-button>
            <el-breadcrumb separator="/" class="bread">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="r-content">
            <el-dropdown>
                <span class="el-dropdown-link">
                    <img :src="getImageUrl('user')" class="user">
                    <el-icon class="el-icon--right">
                        <arrow-down />
                    </el-icon>
                </span>
                <template #dropdown>
                    <el-dropdown-menu>
                        <el-dropdown-item>个人中心</el-dropdown-item>
                        <el-dropdown-item>退出</el-dropdown-item>
                    </el-dropdown-menu>
                </template>
            </el-dropdown>
        </div>
    </div>
</template>

<script setup>
    import {ref,computed} from "vue";
    import {useAllDataStore} from "@/stores/index.js";
    const  store=useAllDataStore();
    const getImageUrl=(user)=>{
      return new URL(`../assets/images/${user}.png`,import.meta.url).href
    }

    const handleCollapse=()=>{
      store.state.isCollapse=!store.state.isCollapse
    }
</script>

<style lang="less" scoped>
.icons {
    width: 20px;
    height: 20px;
}
.header{
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    background-attachment: #333;
}
.r-content{
  .user{
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
}
.l-content{
  display: flex;
  align-items: center;
  .el-button{
    margin-right: 20px;
  }
}
:deep(.bread span) {
  color: #fff !important;
  cursor: pointer !important;
}
</style>